<!--动态通知，自定义组件显示-->
<template>
  <component
    :is="comp"
    :componentData="componentData"
    ref="compModel"
    v-if="comp">
  </component>
</template>
<script>
  export default {
    name: 'ShowDynamicNotice',
    data () {
      return {
        compName: this.path
      }
    },
    computed: {
      comp: function () {
        if(!this.path){
          return null;
        }
        //return () => import(`@/views/${this.path}.vue`)
        //去掉这个编译警告Critical dependency: the request of a dependency is an expression
        return () => Promise.resolve(require(`@/views/${this.path}.vue`).default)
      }
    },
    props:[
      /**
       * 自定义组件路径
       */
      'path',
      /**
       * 组件数据
       */
      'componentData'
    ],
    methods: {
      /**
       * 显示组件
       */
      detail () {
        setTimeout(() => {
          if(this.path){
            this.$refs.compModel.view(this.componentData);
          }
        }, 200)
      },
    }
  }
</script>
